/*
 * @Author: 烟浮
 * @Date: 2022-06-28 16:40:06
 * @LastEditTime: 2022-06-29 01:08:10
 * @LastEditors: 锦墨涵秋 275740441@qq.com
 * @FilePath: /viteDocker/src/utils/cache.ts
 */
/*
 * @Author: 烟浮
 * @Date: 2022-06-18 14:30:32
 * @LastEditTime: 2022-06-18 15:36:20
 * @LastEditors: 锦墨涵秋 275740441@qq.com
 * @FilePath: /vite-haiwai/src/utils/cache.ts
 */
// 本地缓存数据的一些工作

class LocalCache {
  setCache(key: string, value: any) {
    localStorage.setItem(key, JSON.stringify(value))
  }
  getCache(key: string) {
    const value = localStorage.getItem(key)
    if (value) {
      return JSON.parse(value)
    }
  }
  deleteCache(key: string) {
    localStorage.removeItem(key)
  }
  clearCache(key: string) {
    localStorage.clear()
  }
}

export default new LocalCache()
